﻿Public Class Login

    Sub New()
        ' 此调用是设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。
    End Sub

    Private Sub ButtonExit_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonExit.Click
        End
    End Sub

    Private Sub ButtonLogin_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonLogin.Click
        Dim Level As Long
        Dim Main_Form As New MainWindow
        Try
            If UserEnter.identity(TextBoxName.Text, TextBoxPassword.Password, Level) Then
                GlobalClass.UserId = TextBoxName.Text
                Main_Form.Initialize(Level)
                Main_Form.Show()
                Hide()
            End If
        Catch err As Exception
            MsgBox(err.Message)
        End Try
    End Sub

    Private Sub Login_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles Me.Closing
        End
    End Sub

    Private Sub Login_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles Me.KeyDown
        If e.Key = Key.Return Then
            ButtonLogin_Click(sender, New RoutedEventArgs)
        ElseIf e.Key = Key.Escape Then
            ButtonExit_Click(sender, New RoutedEventArgs)
        End If
    End Sub
End Class
